package br.com.aquinoevasconcelos.servlets.orcamento;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import br.com.aquinoevasconcelos.fachada.Fachada;

/**
 * Servlet implementation class EditarOrcamento
 */
@WebServlet("/VerOrcamento")
public class VerOrcamento extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
  
    public VerOrcamento() {
        super();

    }
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    	
    	Fachada fachada = Fachada.getInstancia();
    	
    	
    	String codigo = request.getParameter("id");
    	System.out.println("entrou"+codigo);
    	long id = Long.parseLong(codigo);
    	
    	
    	try {
    		
    		request.setAttribute("verOrcamento", fachada.EditarOrcamento(id));
    		
    		request.getRequestDispatcher("admin/ver_orcamento.jsp").forward(request, response);
			
		} catch (Exception e) {
			request.getRequestDispatcher("../erro.jsp").forward(request, response);
		}
    
    	
    	
    }

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		service(request, response);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		service(request, response);

	}

}
